package com.ln.reactive.msg.test;

import org.reactivestreams.Subscriber;
import org.reactivestreams.Subscription;

public class SubscriberWrapper<T> implements Subscriber<T> {

    /**
     * 来自应用实现
     */
    private Subscriber<T> subscriber;

    /**
     * 内部实现
     */
    private DefaultSubscription subscription;

    public SubscriberWrapper(Subscriber<T> subscriber, DefaultSubscription subscription) {
        this.subscriber = subscriber;
        this.subscription = subscription;
    }

    public Subscriber<T> getSubscriber() {
        return subscriber;
    }

    public DefaultSubscription getSubscription() {
        return subscription;
    }

    @Override
    public void onSubscribe(Subscription s) {
        subscriber.onSubscribe(s);
    }

    @Override
    public void onNext(T t) {
        subscriber.onNext(t);
    }

    @Override
    public void onError(Throwable t) {
        subscriber.onError(t);
    }

    @Override
    public void onComplete() {
        subscriber.onComplete();
    }
}
